package com.tchepannou.limbe.gae.converter;

import com.google.appengine.api.datastore.KeyFactory;
import com.tchepannou.util.converter.Converter;

public class KeyConverter
    implements Converter
{
    //-- Converter overrides
    @Override
    public Object convert(Object value)
    {
        if (value instanceof String)
        {
            try
            {
                return KeyFactory.stringToKey((String)value);
            }
            catch(Exception e)
            {
                return null;
            }
        }
        else
        {
            return null;
        }
    }
}
